// 引入three.js
import * as THREE from "three";
// 创建三维场景
const scene = new THREE.Scene();
// let mesh;

let geometryArray = []; // 需要合并的模型数组
let materialArray = []; // 材

export function CylinderApi(val) {
  let sphere = new THREE.CylinderGeometry(
    val.Cylinder.R,
    val.Cylinder.R,
    val.Cylinder.H
  );
  const color = new THREE.Color(
    `rgb(${val.Color.R},${val.Color.G},${val.Color.B})`
  );
  const material = new THREE.MeshBasicMaterial({
    color: color,
    wireframe: true,
  });
  // let geometryArray = [cubeGeometry1, cubeGeometry2]; // 需要合并的模型数组
  // let materialArray = [meshMaterial, meshMaterial]; // 材

  let mesh = new THREE.Mesh(sphere, material);
  geometryArray.push(sphere);
  materialArray.push(material);

  return [mesh];
}

export function CuboidApi(val) {
  let sphere = new THREE.BoxGeometry(val.Cuboid.L, val.Cuboid.W, val.Cuboid.H);
  const color = new THREE.Color(
    `rgb(${val.Color.R},${val.Color.G},${val.Color.B})`
  );
  const material = new THREE.MeshBasicMaterial({
    color: color,
    wireframe: true,
  });
  let mesh = new THREE.Mesh(sphere, material);
  geometryArray.push(sphere);
  materialArray.push(material);
  return mesh;
}

export function fn() {
  return [geometryArray, materialArray];
}

export let three = [
  {
    ID: 2,
    Type: "Cylinder",
    Visible: true,
    Cylinder: {
      R: "117.6",
      H: "30",
    },
    Color: {
      R: "255",
      G: "251",
      B: "0",
      A: "0",
    },
    TransformMatrix: {
      value:
        "0.327326835353989,0.755928946018454,-0.566946709513841,0,-0.866025403784439,8.32667268468867E-16,-0.5,0,-0.377964473009226,0.654653670707978,0.654653670707977,0,-665.406454732741,1152.5177872814,1152.5177872814,1",
    },
  },
  {
    ID: 4,
    Type: "Cylinder",
    Visible: true,
    Cylinder: {
      R: "103",
      H: "26",
    },
    Color: {
      R: "18",
      G: "150",
      B: "219",
      A: "0",
    },
    TransformMatrix: {
      value:
        "0.327326835353989,0.755928946018454,-0.566946709513841,0,-0.866025403784439,8.32667268468867E-16,-0.5,0,-0.377964473009226,0.654653670707978,0.654653670707977,0,-651.988715940921,1129.27758197126,1129.27758197126,1",
    },
  },
  {
    ID: 6,
    Type: "Cylinder",
    Visible: true,
    Cylinder: {
      R: "161",
      H: "105",
    },
    Color: {
      R: "115",
      G: "101",
      B: "255",
      A: "0",
    },
    TransformMatrix: {
      value:
        "0.327326835353989,0.755928946018454,-0.566946709513841,0,-0.866025403784439,8.32667268468867E-16,-0.5,0,-0.377964473009226,0.654653670707978,0.654653670707977,0,-113.389341902761,196.39610121239,196.3961012124,1",
    },
  },
  {
    ID: 7,
    Type: "Cylinder",
    Visible: true,
    Cylinder: {
      R: "100",
      H: "300",
    },
    Color: {
      R: "255",
      G: "251",
      B: "230",
      A: "0",
    },
    TransformMatrix: {
      value:
        "0.327326835353989,0.755928946018454,-0.566946709513841,0,-0.866025403784439,8.32667268468867E-16,-0.5,0,-0.377964473009226,0.654653670707978,0.654653670707977,0,-9.09494701772928E-13,-4.54747350886464E-13,0,1",
    },
  },
  {
    ID: 8,
    Type: "Cylinder",
    Visible: true,
    Cylinder: {
      R: "18",
      H: "15",
    },
    Color: {
      R: "255",
      G: "255",
      B: "255",
      A: "0",
    },
    TransformMatrix: {
      value: "1,0,0,0,0,1,0,0,0,0,1,0,162,209.99999990314,1050,1",
    },
  },
  {
    ID: 9,
    Type: "Cuboid",
    Visible: true,
    Cuboid: {
      L: "350",
      W: "180",
      H: "350",
    },
    Position: {
      x: 300,
      y: 300,
      z: 300,
    },
    Color: {
      R: "255",
      G: "255",
      B: "255",
      A: "0",
    },
    TransformMatrix: {
      value: "1,0,0,0,0,1,0,0,0,0,1,0,260,209.99999990314,700.000000000001,1",
    },
  },
];
